CREATE OR REPLACE FUNCTION func_insert_or_update() RETURNS void AS $$

DECLARE
  vCOUNT INTEGER := 0;
BEGIN
  SELECT COUNT(*) INTO vCOUNT FROM <OWNER>.FILE_REGISTRY WHERE COD_FILE_REG = 50;
  IF vCOUNT = 1 THEN
    UPDATE <OWNER>.FILE_REGISTRY SET COD_FILE_REG = 50, DRIVER_CLASS = 'jmine.tec.services.input.driver.xml.ServiceXmlTagDriver', FILE_CODE = 'INTEGRACAO-XML-TAG', FREQUENCY = 0, MONTH_DAY = null, PROCESSOR_ID = 'serviceXmlTagProcessor' WHERE COD_FILE_REG = 50;
  ELSE
    INSERT INTO <OWNER>.FILE_REGISTRY (COD_FILE_REG,                                              DRIVER_CLASS,            FILE_CODE, FREQUENCY, MONTH_DAY, PROCESSOR_ID)
                               VALUES (          50, 'jmine.tec.services.input.driver.xml.ServiceXmlTagDriver', 'INTEGRACAO-XML-TAG',         0,      null, 'serviceXmlTagProcessor');
  END IF;
END;
$$ LANGUAGE plpgsql;

SELECT func_insert_or_update();
DROP FUNCTION func_insert_or_update();